#pragma once
#include "engine/renderer/render2d/sprite_renderer.h"
#include "engine/renderer/render2d/particle_renderer.h"
#include "engine/renderer/render2d/elipse_renderer.h"
#include "engine/renderer/render2d/polygon_renderer.h"
#include "engine/renderer/screen_space_renderer.h"
#include "engine/platform/framebuffer.h"

#include "engine/ecs/actor_system.h"
#include "engine/core/camera2d.h"

namespace kanon
{
    class RenderSystem2d
    {
    private:
        std::shared_ptr<FrameBuffer> framebuffer;

        std::shared_ptr<SpriteRenderer> sprite_renderer;
        std::shared_ptr<ParticleRenderer> particle_renderer;
        std::shared_ptr<ElipseRenderer> elipse_renderer;
        std::shared_ptr<PolygonRenderer> polygon_renderer;

        std::shared_ptr<ScreenspaceRenderer> screenspace_renderer;

        uint32_t width;
        uint32_t height;

    public:
        RenderSystem2d(uint32_t width, uint32_t height);
        ~RenderSystem2d() {}

        void Begin();
        void End();

        void SetCamera2D(const std::shared_ptr<Camera2d>& cam);

        void Render(const std::shared_ptr<ActorSystem>& actor_system);
        
        // custom render functions
        void RenderSprites(const std::shared_ptr<ActorSystem>& actor_system);
        void RenderParticleSystem(const std::shared_ptr<ActorSystem>& actor_system);
        void RenderCircles(const std::shared_ptr<ActorSystem>& actor_system);
        void RenderSelected(const std::shared_ptr<ActorSystem>& actor_system, int32_t index);
    };
}
